<%@ page buffer="none" autoFlush="true" pageEncoding="UTF-8" %>
<%@ page import="freemarker.template.*" %>
<%@ page import="freemarker.core.Environment" %>
<%@ page import="freemarker.core.ParseException" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="net.canadensys.dataportal.utils.HibernateUtil" %>
<%@ page import="net.canadensys.dataportal.vascan.config.ConfigManager" %>
<%@ page import="net.canadensys.dataportal.vascan.config.impl.InstallationConfig" %>
<%!
// Copyright (c) 2010 Canadensys
// http://freemarker.sourceforge.net/docs/pgui_config_errorhandling.html
class MyTemplateExceptionHandler implements TemplateExceptionHandler {
    public void handleTemplateException(TemplateException te, Environment env, java.io.Writer out) throws TemplateException {
        try {
            out.write("[ERROR: " + te.getMessage() + "]");
        } catch (IOException e) {
            throw new TemplateException("Failed to print error message. Cause: " + e, env);
        }
    }
}

%>
<%
org.hibernate.Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
try {
	
	hibernateSession.beginTransaction();
	
	Configuration _cfg = new Configuration();
	//_cfg.setTemplateExceptionHandler(new MyTemplateExceptionHandler());
	_cfg.setTemplateExceptionHandler(TemplateExceptionHandler.IGNORE_HANDLER);
	freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
	//String context = "/usr/local/apache2/htdocs/data-portal/webapp";
	//File fh = new File(context);
	//_cfg.setDirectoryForTemplateLoading(fh);
	_cfg.setServletContextForTemplateLoading(application,"/");
	 
	/* Override locale-sensitive number formatting capability of the Java platform */
	_cfg.setNumberFormat("0.######");
	
	/* Get or create a template */
	Template template = _cfg.getTemplate(TEMPLATE_PATH);
	
	/* Process template : default true, false means template is not processed for debug mode */
	boolean PROCESS_TEMPLATE = true;
	
	/* Create a data model */
	Map<Object,Object> root = new HashMap<Object,Object>();
%>